﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ElfTyping.States.GameState.Entities;

namespace ElfTyping.States.GameState.PlayerPassives
{
    public class DoubleShotPassive : PlayerPassive
    {
        const int ProcChance = 20;
        
        List<Enemy> enemiesToAttack = new List<Enemy>();
        GameScript script;

        public DoubleShotPassive()
        {
            Name = "Double Shot";
            Description = ProcChance + "% chance to shoot\ntwo arrows when you\nmake a perfect shot.";
            CardImage = new Animations.Animation(@"Textures\Cards\Passive_DoubleShot");
        }

        public override void OnShoot(GameScript script, Enemy enemy, bool wasPerfect)
        {
            if (wasPerfect && random.Next(1,101) <= ProcChance)
            {
                enemiesToAttack.Add(enemy);
                script.AddEventIn(0.25f, new GameState.EventManager.EventAction(Proc));
                this.script = script;
            }

            base.OnShoot(script, enemy, wasPerfect);
        }

        private void Proc()
        {
            script.AddEnemyToAttack(enemiesToAttack[0]);
            enemiesToAttack.RemoveAt(0);
        }
    }
}
